import getpass
import sys

import stem
import stem.connection
from stem.control import Controller
from stem import Signal
import  time

with Controller.from_port(port = 9051) as controller:
  controller.authenticate("my_password")  # provide the password here if you set one

  bytes_read = controller.get_info("traffic/read")
  bytes_written = controller.get_info("traffic/written")
  controller.new_circuit()
  controller.signal(Signal.HUP)

  print("My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written))
  print("Tor is running version %s" % controller.get_version())
  controller.close()
